package com.bdqn.service;

import com.bdqn.mapper.SysUserMapper;
import com.bdqn.pojo.SysUser;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * SysUserServiceImpl
 *
 * @author LILIBO
 * @since 2022-10-13
 */
@Service("sysUserService")
public class SysUserServiceImpl implements SysUserService {

    // @Autowired // 由Spring提供的注入方式（看类型），将UserDao的实例注入到userDao
    // @Qualifier("userOracleDao") // 配置通过注解的名称查找

    // @Resource // 由JDK提供的注入方式（默认：看名称），将UserDao的实例注入到userDao
    // @Resource(type = UserDaoOracleImpl.class) // 由JDK提供的注入方式（type配置通过类型匹配）
    @Resource // 由JDK提供的注入方式（name配置通过名称匹配）
    private SysUserMapper sysUserMapper;

    /**
     * 获得用户列表
     *
     * @param sysUser
     * @return
     */
    @Transactional(propagation = Propagation.SUPPORTS)
    @Override
    public List<SysUser> getList(SysUser sysUser) {
        return sysUserMapper.selectSysUserList(sysUser);
    }

    /**
     * 保存用户
     *
     * @param sysUser
     * @return
     */
    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public boolean add(SysUser sysUser) {
        return sysUserMapper.add(sysUser)==1;
    }

}
